<?php

/**
 * 获取对用户后台手工操作记录的查询条件
 */
class Application_Model_Filter_UseraccountSearch {

      /**
       *
       *  快速搜索
       */
      public $quick;

      /**
       * 起始时间
       */
      public $stime;

      /**
       * 结束时间
       */
      public $etime;

      /**
       *
       *  状态
       */
      public $state;
      
      /**
       * 
       *  操作类型
       */
      public $operat;

      public function getmyfilter() {
            $where = array();
            $and = '';
            if ($this->quick != NULL) {
                  $array_user = Application_Model_User::getByNikeNameStore($this->quick);
//                  if ($array_user) {
                        $userid = "(";
                        foreach ($array_user as $uvalue) {
                              $userid .= $uvalue->id . ",";
                        }
                        $userid .= "0)";
                        $where['accountId in '] = $userid;
                        $and = ' and ';
//                  } else {
//                        return null;
//                  }
            }

            if ($this->stime != NULL) {
                  $where[$and . ' dateCreated >= '] = $this->stime;
                  $and = ' and ';
            }

            if ($this->etime != NULL) {
                  $where[$and . ' dateCreated <= '] = $this->etime;
                  $and = ' and ';
            }

            if ($this->state != null) {
                  $where[$and . ' state = '] = $this->state;
                  $and = ' and ';
            }
            
            if ($this->operat != null) {
                  $where[$and . " comment like "] = "%" .$this->operat."%";
//                  $where[$and ." comment like "] = "%" . $this->operat . "%";
                  $and = ' and ';
            }
            return $where;
      }

}
